package cn.edu.neusoft.yyd208.foodorder.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.yyd208.foodorder.activity.FoodInfoActivity;
import cn.edu.neusoft.yyd208.foodorder.bean.FoodBean;



public class FoodListAdapter extends BaseAdapter<FoodBean> {
    public FoodListAdapter(Context context, List<FoodBean> items, int layoutResource) {
        super(context, items, layoutResource);
    }


    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        ShopViewHolder myViewHolder=(ShopViewHolder)holder;
        final String id=items.get(position).getShop_id();
        final String foodid=items.get(position).getFood_id();
        final String foodname=items.get(position).getFoodname();
        final String foodintro=items.get(position).getIntro();
        final String foodprice=items.get(position).getPrice();
        final String foodimg=items.get(position).getPic();
        myViewHolder.tv_shop.setText(foodname);
        myViewHolder.tv_address.setText(foodprice);
        myViewHolder.tv_intro.setText(foodintro);
        Picasso.with(context).load( "http://172.24.10.175:8080/foodService" + items.get(position).getPic()).into(myViewHolder.img_shop);
        myViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("TEST", "onClick: ");
                Intent intent=new Intent(context, FoodInfoActivity.class);
                //Bundle bundle=new Bundle();
                intent.putExtra("id",id);
                intent.putExtra("foodname",foodname);
                intent.putExtra("foodprice",foodprice);
                intent.putExtra("foodintro",foodintro);
                //bundle.putInt("foodimg", foodimg);
                //intent.putExtras(bundle);
                intent.putExtra("foodimg",foodimg);
                intent.putExtra("foodid",foodid);
                context.startActivity(intent);
            }
        });

    }

}
